const DB = require('../tools/mysql')

module.exports = async ctx => {
    const w = {}
    if (!ctx.request.body.istest) {
        w['card.show'] = 1
    }

    ctx.body = await DB('card')
        .join('style', 'card.style', '=', 'style.id')
        .select('card.id', 'card.title', 'style.code as style', 'card.recommend', 'card.swiper', 'card.display_url', 'card.swiper_url')
        .where(function() {
        	this.where(w).andWhere('card.swiper', 1)
        })
        .orWhere(function() {
        	this.where(w).andWhere('card.recommend', 1)
        })
}